package cc.vicp.djx314.starfood.dao.order;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;

import cc.vicp.djx314.starfood.domain.account.Personnel;
import cc.vicp.djx314.starfood.domain.account.User;
import cc.vicp.djx314.starfood.domain.order.Order;
import cc.vicp.djx314.starfood.domain.order.OrderDish;

public interface OrderMapper {
	/**
	 * 创建一个order
	 * @param order
	 */
	public void createOrder(Order order);

	/**
	 * 创建一个orderDish
	 * @param orderDish
	 * @param orderId
	 */
	public void createOrderDish(@Param("orderDish") OrderDish orderDish,
			@Param("orderId") Integer orderId);

	/**
	 * 更新order的所有菜式总价的那一项,把对应的orderDish的所有总价的和加起来update进去
	 * @param orderId
	 */
	public void updateOrderBySum(Integer orderId);

	/**
	 * 获取一个订单的详细信息
	 * @param id
	 * @return
	 */
	public Order getOrderForPersonnel(Integer orderId);

	/**
	 * 获取一个order,是还没有处理而且还生效的order的最久远的
	 * @param alreadyDealIds
	 * @return
	 */
	public List<Order> getCurrentOrderForPersonnel(@Param("alreadyDealIds") List<Integer> alreadyDealIds);

	/**
	 * 作废订单
	 * @param orderId 要作废订单的id
	 * @return
	 */
	public void updateOrderCancled(Integer orderId);

	public void updateOrderDishCount(OrderDish orderDish);

	public void updateOrderEnabled(Integer orderId);

	public Double getOrderDishPriceById(Integer orderDishId);

	public void updateOrderInfo(Order order);

	public Order getOrderForFlowById(Integer orderId);

	/**
	 * 更新订单流程状态
	 * @param orderId 订单id
	 * @param status 订单状态
	 * @return
	 */
	public int updateOrderFlowStatus(@Param("orderId") Integer orderId,
			@Param("status") Integer status);

	/**
	 * 抽回订单
	 * @param orderId
	 * @return
	 */
	public int updateOrderDraw(Integer orderId);

	/**
	 * 根据id获取一张已经取消了的订单
	 * @param orderId
	 * @return
	 */
	public Order getOrderCancledById(Integer orderId);

	/**
	 * 恢复作废的订单
	 * @param orderId
	 * @return
	 */
	public int updateOrderUncanceled(Integer orderId);

	/**
	 * 获取今天作废的订单
	 * @param date
	 * @return
	 */
	public List<Order> getCanceledOrderToday(Date date);

	/**
	 * 完结订单
	 * @param orderId 订单id
	 * @param status 订单状态
	 * @return
	 */
	public int updateOrderFlowStatusFinish(@Param("orderId") Integer orderId,
			@Param("status") Integer status,
			@Param("personnel") Personnel personnel);

	public List<Order> getOrdersInfoForUser(User user);
}